
#pragma once
#include "math.h"


class Vector3
{
public:
	float x,y,z;		
	// Default
	Vector3 () {x=y=z=0;}
	// 1D Vector
	Vector3 (float a){x=a; y=z=0;}
	// 2D Vector
	Vector3 (float a,float b) {x=a; y=b; z=0;}
	// 3D Vector
	Vector3( float a, float b, float c) {x=a; y=b; z=c;}
	// n-dim Vector
	Vector3( int n, float a[]);
	// Destructor
	~Vector3() {};

	// Comparison (dimension must match, or not)
	int operator==(const Vector3&)const;
	int operator!=(const Vector3&)const;
	Vector3 operator-();                // unary minus
	Vector3 operator~();                // unary 2D perp operator
	friend Vector3 operator*( int,const Vector3&);
	friend Vector3 operator*( float,const Vector3&);
	//friend Vector3 operator*( const Vector3&, int);
	Vector3 operator*(float c)
	{
		Vector3 v;
		v.x = c * x;
		v.y = c * y;
		v.z = c * z;
		return v;
	}
	// Scalar Division
	friend Vector3 operator/( const Vector3&, int);
	friend Vector3 operator/( const Vector3&, float);

	//----------------------------------------------------------
	// Vector Arithmetic Operations
	Vector3 operator+(const Vector3&)const;        // vector add
	//Vector3 operator-(const Vector3&)const;        // vector subtract
	Vector3 operator-( const Vector3& w )const  {
		Vector3 v;
		v.x = x - w.x;
		v.y = y - w.y;
		v.z = z - w.z;
		return v;
	}
	float operator*( const Vector3&)const;			  // inner dot product
	float operator|( const Vector3&)const;           // 2D exterior perp product
	Vector3 operator^(const Vector3&)const;        // 3D exterior cross product

	Vector3& operator*=( float);      // vector scalar mult
	Vector3& operator/=( float);      // vector scalar div
	Vector3& operator+=( const Vector3&);      // vector increment
	Vector3& operator-=( const Vector3&);      // vector decrement
	Vector3& operator^=( const Vector3&);      // 3D exterior cross product
	Vector3 cross( const Vector3&)const;
	Vector3 cross(  Vector3&,   Vector3& );
	float dot( const Vector3& vec )const;

	//----------------------------------------------------------
	// Vector Properties
	float len() const{                    // vector length
		return sqrt(x*x + y*y + z*z);
	}
	float len2() const {                   // vector length squared (faster)
		return (x*x + y*y + z*z);
	}

	//----------------------------------------------------------
	// Special Operations
	void normalize();                // convert vector to unit length
	void setValue(float _x,float _y,float _z);
	friend Vector3 sum( int, int[], Vector3[]);     // vector sum
	friend Vector3 sum( int, float[], Vector3[]);  // vector sum
};